﻿using System.Collections.ObjectModel;
using Ninject.Core.Parameters;
using TestBat.IModels.Domain;
using TestBat.IModels.Models;
using TestBat.IViewModels.Base;
using TestBat.IViewModels.Workspaces.Schedules;
using TestBat.ServiceLocator;

namespace TestBat.ViewModels.Workspaces.Schedules
{
    public class ScheduleTraineeGroupListViewModel : ListViewModel<IScheduleTraineeGroupViewModel, ObservableCollection<IScheduleTraineeGroupViewModel>>, IScheduleTraineeGroupListViewModel
    {
        public ScheduleTraineeGroupListViewModel(ISchedule schedule, IScheduleModel scheduleModel)
            : base(false)
        {
            this.schedule = schedule;
            this.scheduleModel = scheduleModel;
        }

        protected override ObservableCollection<IScheduleTraineeGroupViewModel> _RecreateItems()
        {
            ObservableCollection<IScheduleTraineeGroupViewModel> list = new ObservableCollection<IScheduleTraineeGroupViewModel>();

            foreach (IScheduleTraineeGroup item in scheduleModel.GetScheduleTraineeGroups(schedule))
            {
                var vm = DefaultServiceLocator.Get<IScheduleTraineeGroupViewModel>(With.Parameters.ConstructorArgument("traineeGroup", item)); // TODO: DI
                list.Add(vm);
            }

            return list;
        }

        private readonly ISchedule schedule;
        private readonly IScheduleModel scheduleModel;
    }
}
